<template>
  <el-table :data="productList" style="width: 100%;">
    <el-table-column prop="id" width="180" label="商品ID"></el-table-column>
    <el-table-column prop="name" width="180" label="商品名称"></el-table-column>
    <el-table-column prop="price" width="180" label="单价"></el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button type="primary" size="mini" icon="el-icon-plus" @click="addToCart( scope.row )">加入购物车</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import { mapGetters, mapActions } from 'vuex'
export default {
  name: 'goods',
  computed: {
    ...mapGetters(['productList'])
  },
  methods: {
    ...mapActions(['addToCart'])
  }
}
</script>

<style scoped>

</style>
